package czy.demo.endpoint;

import czy.demo.pojo.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Component
@Path("/person")
public class PersonEndpoint {

    private static final Logger logger = LoggerFactory.getLogger(PersonEndpoint.class);

    @GET()
    @Path("/get/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Person getPerson(@PathParam("id") Integer id){
        logger.info("获取 person , id = "+id);
        return null;
    }

    @POST()
    @Path("/create")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.TEXT_PLAIN)
    public String createPerson(Person person){
        logger.info("创建 person："+person.toString());
        return "创建成功";
    }

    @PUT()
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.TEXT_PLAIN)
    public String updatePerson(@BeanParam Person person){
        logger.info("更新 person："+person.toString());
        return "更新成功";
    }

    @DELETE()
    @Path("/delete/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Person deletePerson(@PathParam("id") Integer id){
        logger.info("删除 person , id = "+id);
        return null;
    }




}
